package routers

import (
	"gf-assistant/internal/common"
	"gf-assistant/internal/project"
	"gf-assistant/internal/system"

	"github.com/gogf/gf/v2/net/ghttp"
)

// LoadRoutes 路由配置
func LoadRoutes(s *ghttp.Server) *ghttp.Server {
	var oai = s.GetOpenApi()
	// OpenApi自定义信息
	oai.Info.Title = `项目助手API在线文档`
	oai.Config.CommonResponse = common.BaseResponse{}
	oai.Config.CommonResponseDataField = `Data`
	s.Group("/", func(group *ghttp.RouterGroup) {
		group.Middleware(
			GetMiddleware().Ctx,
			GetMiddleware().ResponseHandler,
		)
		group.Bind(system.Login)
		//登录验证
		group.Middleware(GetMiddleware().Auth)
		group.Group("/index", func(group *ghttp.RouterGroup) { group.Bind(system.Index) })
		group.Group("/system", func(group *ghttp.RouterGroup) {
			group.Group("/user", func(group *ghttp.RouterGroup) { group.Bind(system.User) })
			group.Group("/role", func(group *ghttp.RouterGroup) { group.Bind(system.Role) })
			group.Group("/menu", func(group *ghttp.RouterGroup) { group.Bind(system.Menu) })
			group.Group("/org", func(group *ghttp.RouterGroup) { group.Bind(system.Org) })
		})
		group.Group("/project", func(group *ghttp.RouterGroup) {
			group.Bind(project.Project)
			group.Group("/member", func(group *ghttp.RouterGroup) { group.Bind(project.Member) })
			group.Group("/task", func(group *ghttp.RouterGroup) { group.Bind(project.Task) })
		})
	})
	return s
}
